﻿//Point.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace codeding.KMeans.DataStructures
{
    public class Point
    {
        #region Properties

        public string UserId { get; set; }
        public double Sim { get; set; }

        #endregion

        #region Constructors

        public Point()
        {
            UserId = "";
            Sim = -1;
        }

        public Point(double sim)
        {
            this.UserId = "";
            this.Sim = sim;
        }

        public Point(string UserIdPair, double sim)
        {
            this.UserId = UserIdPair;
            this.Sim = sim;
        }

        #endregion

        #region Methods

        public bool IsBetween(Point p1, Point p2)
        {
            if (this.Sim >= p1.Sim && this.Sim <= p2.Sim)
            {
                return (true);
            }

            return (false);
        }

        public override bool Equals(object obj)
        {
            if (obj is Point)
            {
                Point point = (Point)obj;
                if (this.Sim == point.Sim )
                {
                    return (true);
                }
            }

            return (false);
        }

        public override string ToString()
        {
            return ("{" + this.Sim + "}");
        }

        #endregion

        #region Static-Methods

        public static double FindDistance(Point pt1, Point pt2)
        {
            double x1 = pt1.Sim;
            double x2 = pt2.Sim;

            //find euclidean distance
            double distance = Math.Sqrt(Math.Pow(x2 - x1, 2.0));
            return (distance);
        }

        #endregion
    }
}
